home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Taifun / Taifun 007 (1987-02-15)(Ossowski, Stefan)(DE)(PD).zip / Taifun 007 (1987-02-15)(Ossowski, Stefan)(DE)(PD).adf / C Compiler / searchkw.c < prev    next >
C/C++ Source or Header  |  1987-03-04  |  2KB  |  54 lines

  1. #include        <stdio.h>
  2. #include        "c.h"
  3. #include        "expr.h"
  4. #include        "gen.h"
  5. #include        "cglbdec.h"
  6.  
  7. /*
  8.  *    68000 C compiler
  9.  *
  10.  *    Copyright 1984, 1985, 1986 Matthew Brandt.
  11.  *    all commercial rights reserved.
  12.  *
  13.  *    This compiler is intended as an instructive tool for personal use. Any
  14.  *    use for profit without the written consent of the author is prohibited.
  15.  *
  16.  *    This compiler may be distributed freely for non-commercial use as long
  17.  *    as this notice stays intact. Please forward any enhancements or questions
  18.  *    to:
  19.  *
  20.  *        Matthew Brandt
  21.  *        Box 920337
  22.  *        Norcross, Ga 30092
  23.  */
  24.  
  25. struct kwblk {
  26.         char *word;
  27.         enum e_sym stype;
  28.         } keywords[] = {
  29.  
  30.         {"int", kw_int}, {"char", kw_char}, {"long", kw_long},
  31.         {"float", kw_float}, {"double", kw_double}, {"return", kw_return},
  32.         {"struct", kw_struct}, {"union", kw_union}, {"typedef", kw_typedef},
  33.         {"enum", kw_enum}, {"static", kw_static}, {"auto", kw_auto},
  34.         {"sizeof", kw_sizeof}, {"do", kw_do}, {"if", kw_if},
  35.         {"else", kw_else}, {"for", kw_for},{"switch", kw_switch},
  36.         {"while", kw_while},{"short", kw_short}, {"extern", kw_extern},
  37.         {"case", kw_case}, {"goto", kw_goto}, {"default", kw_default},
  38.         {"register", kw_register}, {"unsigned", kw_unsigned},
  39.         {"break", kw_break}, {"continue", kw_continue}, {"void", kw_void},
  40.         {0, 0} };
  41.  
  42. enum e_sym searchkw()
  43. {
  44.     struct kwblk    *kwbp;
  45.         kwbp = keywords;
  46.         while(kwbp->word != 0) {
  47.                 if(strcmp(lastid,kwbp->word) == 0)
  48.                         return (lastst = kwbp->stype);
  49.                 else
  50.                         ++kwbp;
  51.                 }
  52.     return (lastst);
  53. }
  54.